/*
 * Element.h
 *
 *  Created on: 2011/07/26
 *      Author: naoki
 */

#ifndef INCLUDED_NTENGINE_XML_ELEMENT_H
#define INCLUDED_NTENGINE_XML_ELEMENT_H

namespace NTEngine {
class OStringStream;
namespace Xml {
using namespace std;

class Attribute;
class ConstAttribute;
class ConstElement;

///エレメント
class Element{
public:
	int attributeNumber() const;
	void setAttributeNumber( int );
	Attribute attribute( int i );
	ConstAttribute attribute( int i ) const;

	int childNumber() const;
	void setChildNumber( int );
	Element child( int i );
	ConstElement child( int i ) const;

	const char* name() const;
	void setName( const char* );

	void convertToString( OStringStream* out ) const;

	//以下使用者は意識しなくて良い。
	Element();
	Element( const Element& );
	~Element();
	operator void*() const;
	Element& operator=( const Element& );
	void release();
	bool operator==( const Element& ) const;
	bool operator!=( const Element& ) const;
	int referenceCount() const;

	class Impl;
private:
	friend class Document;

	explicit Element( Impl* );
	Impl* mImpl;
};

class ConstElement{
public:
	int attributeNumber() const;
	ConstAttribute attribute( int i ) const;
	int childNumber() const;
	ConstElement child( int i ) const;
	const char* name() const;
	void convertToString( OStringStream* out ) const;

	//以下知らなくていい
	ConstElement();
	ConstElement( const Element& );
	~ConstElement();
	ConstElement& operator=( const Element& );
	void release();
	operator void*() const;
	bool operator==( const Element& ) const;
	bool operator!=( const Element& ) const;
private:
	Element mBase;
};

} //namespace Xml
} //namespace NTEngine

#endif // INCLUDED_NTENGINE_XML_ELEMENT_H
